import loader from "@assemblyscript/loader";
import moize from "moize";

export const loadModule = moize(
    (path: string, setting?: Parameters<typeof loader.instantiate>[1]) =>
        fetch(path)
            .then((res) => res.arrayBuffer())
            .then((buffer) => loader.instantiate(buffer, setting))
            .then(({ exports }) => exports)
);
